﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _2_3
{
  
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
           
            txtResult.ReadOnly = true;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
              
                double num = Convert.ToDouble(txtNum.Text);
                int result;
                
                if (num < 0)
                {
                    result = -1;
                }
                else if (num == 0)
                {
                    result = 0;
                }
                else
                {
                    result = 1;
                }
                
                txtResult.Text = result.ToString();
            }
            catch (FormatException)
            {
                
                MessageBox.Show("请输入有效的数字！");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            
            txtNum.Text = "";
            txtResult.Text = "";
        }
    }
}